# ommbot/examples.py
#
#

""" examples is a dict of example objects """

__copyright__ = 'this file is in the public domain'

import re

class Examples(dict):

    """ examples object is a dict """

    def add(self, name, descr, ex):
        """ add description and example """
        self[name.lower()] = (descr, ex)

    def size(self):
        """ return size of examples dict """
        return len(self.keys())

    def getexamples(self):
        """ get all examples in list """
        result = []
        for i in self.values():
            ex = i[1].lower()
            exampleslist = re.split('\d\)', ex)
            for example in exampleslist:
                if example:
                    result.append(example.strip())
        return result
